<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        let a = [1,3,5,7,9]
        let b = [2,4,6,8,10]
        console.log(...a)   //展开一个数组

        let c = [...a,...b]
        console.log(...c)   //连接一个数组

        //在函数中使用
        function sum (...numbers){
            return numbers.reduce((preValue,currentValue) =>{
                return preValue + currentValue
            })
        }
        console.log(sum(1,2,3,4,5,6))

        //构造字面量对象是使用语法
        let person = {name:'tom', age:18}
        let person2 = {...person}   //复制person
        // console.log(...person)  //报错，展开运算符不能展开对象
        console.log('person2',person2)  
        person.name = 'jerry'
        console.log(person2)
        console.log(person)


        //合并
        let per = {name:'make', age:20}
        let pers = {...person,...per}
        let pers2 = {...person,name:'mamo',address:'重庆'}
        console.log(pers)
        console.log(pers2)
    </script>
</body>
</html>